package com.blog.personalblog.config.mail;

import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class SendMailConfig {
    public static void sendMail(MailInfo mailInfo){
        try{
            MailAccount account = new MailAccount();
            account.setHost("smtp.126.com");
            account.setPort(25);
            account.setFrom("liuaiguo_cn@126.com");
            account.setPass("VLTWJSNIHFLMCNUD");
            account.setSslEnable(false);
            MailUtil.send(account,mailInfo.getReceiveMail(),mailInfo.getTitle(),mailInfo.getContent(),false);
            log.info("邮件发送成功");
        }catch(Exception e){
            log.error("邮件发送失败" + JSONUtil.toJsonStr(mailInfo));
        }
    }
}
